<template>
  <div class="mainbox">
   
    <div class="blogBox">
      <el-col
        :span="20"
        v-for="(blog, index) in Blogs"
        :key="blog.id"
        :offset="(index = 0)"
      >
        <el-card class="blogCard" shadow="always">
          <a :href="'#/showBlog?id=' + blog.id"
            ><h1 class="animate__animated animate__zoomInDown">
              {{ blog.title }}
            </h1></a
          >
          <p class="p2">{{ blog.summary }}</p>
          <p>{{ blog.time }}</p>
        </el-card>
        <!-- <el-divider></el-divider> -->
      </el-col>
      <el-pagination
        class="pageBox"
        background
        layout="prev, pager, next"
        :total="total"
        :current-page="currentPage"
        :page-size="pageSize"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
// import AvatarUploader from "../components/AvatarUploader/index.vue";
export default {
  // components: { AvatarUploader },
  name: "SearchBlog",
  data() {
    return {
      currentPage: 1, //初始页
      pageSize: 6, //    每页的数据
      total: 1,
      Blogs: [],
      blog: {
        title: "",
      },
    };
  },
  methods: {
    
    handleSizeChange(pageSize) {
      this.pageSize = pageSize;
      // 点击每页显示的条数时，显示第一页
      this.showDataAll(this.currentPage, this.pageSize);
    },
    showDataAll(currentPage, pageSize) {
      var _this = this;
       _this.Blogs = [];
        _this.total = 1;
      var searchBlogID = localStorage.getItem("searchBlogID");
      this.$axios.get("http://120.77.71.211:9011/api/getSearchList/" + currentPage + "/" + pageSize+"?title="+searchBlogID).then(
        (resp) => {
          _this.Blogs = resp.list;
          _this.total = resp.total;
        }
      );
    },
    handleCurrentChange(currentPage) {
      this.currentPage = currentPage;
      // 点击每页显示的条数时，显示第一页
      this.showDataAll(this.currentPage, this.pageSize);
    },
  },
  mounted() {
    this.showDataAll(1, 6);
  },
  created() {
  },
};
</script>

<style scoped>
.mainbox {
  margin-left: 10px;
  width: 1350px;
  height: 750px;
  /* border: 1px solid black; */
}
.blogBox {
  float: left;
  text-align: left;
  margin: 0px auto;
  margin-left: 10px;
  width: 600px;
}
.blogCard {
  line-height: 18px;
  width: 570px;
  /* height: 1%; */
  background: rgba(245, 247, 248, 0.8);
}
.pageBox {
  float: right;
  margin-right: 20px;
}
.animate__zoomInDown {
  margin-top: 0px;
  font-size: 23px;
}
a:link {
  color: rgb(67, 72, 145);
}
a:visited {
  color: rgb(67, 72, 145);
}
a {
  text-decoration: none;
}
/* .p1{
  margin-top: 10%;
  font-size: 12%;
} */
p {
  line-height: 10px;
  font-size: 10px;
}
.p2 {
  font-size: 15px;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>